package org.firefly.db.util;

import java.util.ArrayList;
import java.util.List;

import org.firefly.db.meta.ColumnMeta;

public class CompUtils {
	/**
	 * 提取指定类别的不同列信息
	 * @param cms
	 * @param diffType
	 * @return
	 */
	public static List<ColumnMeta> subColumns(List<CompColumnMeta> cms,int diffType){
		List<ColumnMeta> ls = new ArrayList<ColumnMeta>();
		for (CompColumnMeta ccm : cms) {
			switch(diffType){
			case CompColumnMeta.TYPE_ADDCOLUMN:
				if(ccm.addColumn)ls.add(ccm.cm);
				break;
			case CompColumnMeta.TYPE_DELCOLUMN:
				if(ccm.delColumn)ls.add(ccm.cm);
				break;
			case CompColumnMeta.TYPE_DIFFLENGTH:
				if(ccm.diffLength)ls.add(ccm.cm);
				break;
			case CompColumnMeta.TYPE_DIFFTYPE:
				if(ccm.diffType)ls.add(ccm.cm);
				break;
			}
		}
		return ls;
	}
}
